﻿//++
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// Module Name:
//
//    NotificationChannelTest.cs
//
// Abstract:
//    
//    Unit tests for OCS-stored channels.
//
//--

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Microsoft.EnhancedReminders.Common.UnitTests
{    
    /// <summary>
    ///This is a test class for NotificationChannelTest and is intended
    ///to contain all NotificationChannelTest Unit Tests
    ///</summary>
    [TestClass()]
    public class NotificationChannelTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        /// <summary>
        ///A test for NotificationChannel Constructor
        ///</summary>
        [TestMethod()]
        public void NotificationChannelConstructorTest()
        {
            NotificationChannel channel = new NotificationChannel();
            Assert.AreEqual(NotificationChannelType.Communicator, channel.NotificationChannelType, "NotificationChannelType");
            Assert.AreEqual(NotificationChannel.CommunicatorId, channel.Id, "Id");

            channel = new NotificationChannel(NotificationChannelType.Communicator);
            Assert.AreEqual(NotificationChannelType.Communicator, channel.NotificationChannelType, "NotificationChannelType");
            Assert.AreEqual(NotificationChannel.CommunicatorId, channel.Id, "Id");

            channel = new NotificationChannel(NotificationChannelType.Phone);
            Assert.AreEqual(NotificationChannelType.Phone, channel.NotificationChannelType, "NotificationChannelType");
            Assert.AreEqual(NotificationChannel.MobilePhoneId, channel.Id, "Id");

            channel = new NotificationChannel(NotificationChannelType.Phone, "name", "value");
            Assert.AreEqual(NotificationChannelType.Phone, channel.NotificationChannelType, "NotificationChannelType");
            Assert.AreEqual(NotificationChannel.MobilePhoneId, channel.Id, "Id");

            channel = new NotificationChannel(NotificationChannel.OtherPhoneId, "name", "value");
            Assert.AreEqual(NotificationChannelType.Phone, channel.NotificationChannelType, "NotificationChannelType");
            Assert.AreEqual(NotificationChannel.OtherPhoneId, channel.Id, "Id");      
        }

        /// <summary>
        ///A test for NotificationCustomChannel Copy() method.
        ///</summary>
        [TestMethod()]
        public void VerifyCopyMethod()
        {
            NotificationChannel originalChannel = new NotificationChannel(NotificationChannel.HomePhoneId, "name", "value");

            NotificationChannel copyChannel = originalChannel.Copy();

            Assert.IsTrue(copyChannel.GetType() == typeof(NotificationChannel), "Expected OCS channel");
            Assert.AreEqual(originalChannel.Id, copyChannel.Id, "Id");
            Assert.AreEqual(originalChannel.NotificationChannelType, copyChannel.NotificationChannelType, "NotificationChannelType");
            Assert.AreEqual(originalChannel.UserDefinedName, copyChannel.UserDefinedName, "UserDefinedName");
            Assert.AreEqual(originalChannel.UserDefinedValue, copyChannel.UserDefinedValue, "UserDefinedValue");
        }
    }
}
